package com.itfreer.power.service.power.strategy;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.form.dictionary.DictionaryManage;
import com.itfreer.form.dictionary.base.DictionaryItem;

/**
 * 地图范围权限数据提供接口
 */
@Component("MemoryMapExtentJurisdictionDataProvide")
public class MemoryMapExtentJurisdictionDataProvide implements MapExtentJurisdictionDataProvide {

	@Autowired
	private DictionaryManage dictionaryManage;

	private static final String mapextentDic = "p_mapextent_jurisdiction";

	@Override
	public List<String> getMapExtent(List<String> mapExtentIDs, String serviceId) {
		if (mapExtentIDs == null || mapExtentIDs.size() <= 0) {
			return null;
		}
		List<String> result = new ArrayList<String>();
		for (String mapExtentID : mapExtentIDs) {
			DictionaryItem item = dictionaryManage.getDictionary(mapextentDic, mapExtentID);
			if (item != null && item.getOther().get("registerService").toString().equals(serviceId)) {
				if (item.getOther().containsKey("mapExtents") && item.getOther().get("mapExtents") != null) {
					result.add(item.getOther().get("mapExtents").toString());
				}
			}
		}
		return result;
	}
}